﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using IDAL;
using Model;

namespace DAL
{
    public class TPIMTestItem : BaseRepository<TPIMTestItemInfo>, ITPIMTestItem
    {
        private const string PARM_TPIMTESTITEM_PRODUCTSN = "@ProductSN";
        private const string PARM_TPIMTESTITEM_RECORDTIME = "@RecordTime";

        public IList<TPIMTestItemInfo> GetTPIMTestItembySNDT(string productSN, DateTime recordTime)
        {
            SqlParameter[] parms = GetParameters();
            //Bind the parameter
            parms[0].Value = productSN;
            parms[1].Value = recordTime;
            return ExcuteSqlToGetEntities("TPIMTestItem_selectbySNDT", parms);
        }

        public IList<TPIMTestItemInfo> GetTPIMTestItembySN(string productSN)
        {
            SqlParameter parm = GetParameter();
            //Bind the parameter
            parm.Value = productSN;
            return ExcuteSqlToGetEntities("TPIMTestItem_selectbySN", parm);
        }


        //-------------------------------------重写超类基础操作---------------------------------------------------------

        public override TPIMTestItemInfo GetEntityRecord(SqlDataReader rdr)
        {
            TPIMTestItemInfo pro = new TPIMTestItemInfo(rdr.GetValue(0).ToString(), rdr.GetDateTime(1), rdr.GetValue(2).ToString(), rdr.GetDecimal(3));
            return pro;
        }

        public override SqlParameter GetParameter()
        {
            SqlParameter parms = new SqlParameter(PARM_TPIMTESTITEM_PRODUCTSN, SqlDbType.NVarChar, 50);
            return parms;
        }

        public override SqlParameter[] GetParameters()
        {
            SqlParameter[] parms = null;
            parms = new SqlParameter[]
                {
					new SqlParameter(PARM_TPIMTESTITEM_PRODUCTSN, SqlDbType.NVarChar, 50),
                    new SqlParameter(PARM_TPIMTESTITEM_RECORDTIME, SqlDbType.DateTime, 8),
                };
            return parms;
        }
    }
}
